import 'package:flutter_learn_vi/src/net/dio_utils.dart';
import 'package:get/get.dart';

import '../../../../bean/bean_day_stat.dart';

class QuestionDetailsController extends GetxController {
  bool _isLoading = true;
  BeanDayStat newsBean;

  int id;

  QuestionDetailsController(this.id);

  Future<bool> requestGoodsList() async {
    Map<String, dynamic> map = Map();
    _isLoading = true;
    //
    ResponseInfo responseInfo = await DioUtils.instance
        .postRequest(url: HttpHelper.appQuestionDetails + "$id", jsonMap: map);
    _isLoading = false;
    if (responseInfo.success) {
      newsBean = BeanDayStat.fromMap(responseInfo.data);
    } else {
      newsBean = null;
    }

    update();
    return true;
  }

  Future<bool> onPullRefresh({int index = 0}) async {
    await requestGoodsList();
    return true;
  }

  bool get isLoading => _isLoading;

  @override
  void onReady() {
    super.onReady();
    requestGoodsList();
  }
}
